package com.zhao.controller;


import com.zhao.Result;
import com.zhao.entity.EduSubject;
import com.zhao.entity.subject.OneSubject;
import com.zhao.service.EduSubjectService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.util.ArrayList;
import java.util.List;

/**
 * <p>
 * 课程科目 前端控制器
 * </p>
 *
 * @author testjava
 * @since 2021-07-01
 */
@RestController
@RequestMapping("/eduservice/subject")
@CrossOrigin
public class EduSubjectController {

    @Autowired
    private EduSubjectService subjectService;

    //添加课程分类信息
    @PostMapping("/addSubject")
    public Result addSubject(MultipartFile file){
        subjectService.saveSubject(file,subjectService);
        return Result.ok();
    }
    //查询课程信息
    @PostMapping("/list")
    public Result list(){
        //查询所有的课程信息(树形结构)
       List<OneSubject>subjectList= subjectService.selectAll();
       return Result.ok().data("subjectList",subjectList);
    }

}

